home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-08-10 | 14.5 KB | 327 lines | [TEXT/MPS ] |
- (*
- File: SoundComponents.mod
-
- Contains: Sound Components Interfaces.
-
- Version: Technology: System 7.5
- Package: Universal Interfaces 2.0 in “MPW Latest” on ETO #17
-
- Copyright: © 1984-1995 by Apple Computer, Inc.
- All rights reserved.
-
- Bugs?: If you find a problem with this file, use the Apple Bug Reporter
- stack. Include the file and version information (from above)
- in the problem description and send to:
- Internet: apple.bugs.applelink.apple.com
- AppleLink: APPLE.BUGS
-
- *)
-
- (*$TAGS-*)
- (*$CALLING PASCAL*)
- MODULE SoundComponents;
-
- IMPORT SYSTEM, Types, Components, Sound;
-
- (* $PUSH*)
- (* $ALIGN MAC68K*)
- (* $LibExport+*)
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
- (* constants*)
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
-
- CONST
- (*sound component set/get info selectors*)
- siVolume* = LONG("volu");
- siHardwareVolume* = LONG("hvol");
- siSpeakerVolume* = LONG("svol");
- siHeadphoneVolume* = LONG("pvol");
- siHardwareVolumeSteps* = LONG("hstp");
- siHeadphoneVolumeSteps* = LONG("hdst");
- siHardwareMute* = LONG("hmut");
- siSpeakerMute* = LONG("smut");
- siHeadphoneMute* = LONG("pmut");
- siRateMultiplier* = LONG("rmul");
- siQuality* = LONG("qual");
- (*format types*)
- kOffsetBinary* = LONG("raw ");
- kTwosComplement* = LONG("twos");
- kMACE3Compression* = LONG("MAC3");
- kMACE6Compression* = LONG("MAC6");
-
- (*quality flags*)
- (*use interpolation in rate conversion*)
- kBestQuality* = ASH(1,0);
-
- (*useful bit masks*)
- kInputMask* = $000000FF; (*masks off input bits*)
- kOutputMask* = $0000FF00; (*masks off output bits*)
- kOutputShift* = 8; (*amount output bits are shifted*)
- kActionMask* = $00FF0000; (*masks off action bits*)
- kSoundComponentBits* = $00FFFFFF;
-
- (*SoundComponentPlaySourceBuffer action flags*)
- kSourcePaused* = ASH(1,0);
- kPassThrough* = ASH(1,16);
- kNoSoundComponentChain* = ASH(1,17);
- (*flags for OpenMixerSoundComponent*)
- kNoMixing* = ASH(1,0); (*don't mix source*)
- kNoSampleRateConversion* = ASH(1,1); (*don't convert sample rate (i.e. 11 kHz -> 22 kHz)*)
- kNoSampleSizeConversion* = ASH(1,2); (*don't convert sample size (i.e. 16 -> 8)*)
- kNoSampleFormatConversion* = ASH(1,3); (*don't convert sample format (i.e. LONG("twos") -> LONG("raw "))*)
- kNoChannelConversion* = ASH(1,4); (*don't convert stereo/mono*)
- kNoDecompression* = ASH(1,5); (*don't decompress (i.e. LONG("MAC3") -> LONG("raw "))*)
- kNoVolumeConversion* = ASH(1,6); (*don't apply volume*)
- kNoRealtimeProcessing* = ASH(1,7); (*won't run at interrupt time*)
-
- (*Audio Components.Component constants*)
- (*Values for whichChannel parameter*)
- audioAllChannels* = 0; (*All channels (usually interpreted as both left and right)*)
- audioLeftChannel* = 1; (*Left channel*)
- audioRightChannel* = 2; (*Right channel*)
- (*Values for mute parameter*)
- audioUnmuted* = 0; (*Device is unmuted*)
- audioMuted* = 1; (*Device is muted*)
- (*Capabilities flags definitions*)
- audioDoesMono* = ASH(1,0); (*Device supports mono output*)
- audioDoesStereo* = ASH(1,1); (*Device supports stereo output*)
- audioDoesIndependentChannels* = ASH(1,2); (*Device supports independent software control of each channel*)
-
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
- (* typedefs*)
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
- (*ShortFixed consists of an 8 bit, 2's complement integer part in the high byte,*)
- (*with an 8 bit fractional part in the low byte; its range is -128 to 127.99609375*)
-
- TYPE
- ShortFixed* = INTEGER;
-
- SoundComponentDataPtr* = POINTER TO SoundComponentData;
-
- SoundComponentData* = RECORD
- flags*: LONGINT;
- format*: Types.OSType;
- numChannels*: INTEGER;
- sampleSize*: INTEGER;
- sampleRate*: Sound.UnsignedFixed;
- sampleCount*: LONGINT;
- buffer*: SYSTEM.PTR (*ΔΔ POINTER TO Types.Byte*);
- reserved*: LONGINT;
- END;
-
- SoundParamBlockPtr* = POINTER TO SoundParamBlock;
-
- SoundParamProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE (VAR pb: SoundParamBlockPtr): BOOLEAN;
- SoundParamUPP* = Types.UniversalProcPtr;
-
- SoundParamBlock* = RECORD
- recordSize*: LONGINT; (*size of this record in bytes*)
- desc*: SoundComponentData; (*description of sound buffer*)
- rateMultiplier*: Sound.UnsignedFixed; (*rate multiplier to apply to sound*)
- leftVolume*: INTEGER; (*volumes to apply to sound*)
- rightVolume*: INTEGER;
- quality*: LONGINT; (*quality to apply to sound*)
- filter*: Components.ComponentInstance; (*filter to apply to sound*)
- moreRtn*: SoundParamUPP; (*routine to call to get more data*)
- completionRtn*: SoundParamUPP; (*routine to call when buffer is complete*)
- refCon*: LONGINT; (*user refcon*)
- result*: INTEGER; (*result*)
- END;
-
- SoundSource* = Types.Ptr;
-
- AudioInfo* = RECORD
- capabilitiesFlags*: LONGINT; (*Describes device capabilities*)
- reserved*: LONGINT; (*Reserved by Apple*)
- numVolumeSteps*: INTEGER; (*Number of significant increments between min and max volume*)
- END;
-
- AudioInfoPtr* = POINTER TO AudioInfo;
-
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
- (* functions for sound components*)
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
- (*Sound Components.Component dispatch selectors*)
-
- CONST
- (*these calls cannot be delegated*)
- kSoundComponentInitOutputDeviceSelect* = 1;
- kSoundComponentSetSourceSelect* = 2;
- kSoundComponentGetSourceSelect* = 3;
- kSoundComponentGetSourceDataSelect* = 4;
- kSoundComponentSetOutputSelect* = 5;
- kDelegatedSoundComponentSelectors* = $0100; (*first selector that can be delegated up the chain*)
- (*these calls can be delegated and have own range*)
- kSoundComponentAddSourceSelect* = kDelegatedSoundComponentSelectors + 1;
- kSoundComponentRemoveSourceSelect* = kDelegatedSoundComponentSelectors + 2;
- kSoundComponentGetInfoSelect* = kDelegatedSoundComponentSelectors + 3;
- kSoundComponentSetInfoSelect* = kDelegatedSoundComponentSelectors + 4;
- kSoundComponentStartSourceSelect* = kDelegatedSoundComponentSelectors + 5;
- kSoundComponentStopSourceSelect* = kDelegatedSoundComponentSelectors + 6;
- kSoundComponentPauseSourceSelect* = kDelegatedSoundComponentSelectors + 7;
- kSoundComponentPlaySourceBufferSelect* = kDelegatedSoundComponentSelectors + 8;
-
- (*Audio Components.Component selectors*)
- kAudioGetVolumeSelect* = 0;
- kAudioSetVolumeSelect* = 1;
- kAudioGetMuteSelect* = 2;
- kAudioSetMuteSelect* = 3;
- kAudioSetToDefaultsSelect* = 4;
- kAudioGetInfoSelect* = 5;
- kAudioGetBassSelect* = 6;
- kAudioSetBassSelect* = 7;
- kAudioGetTrebleSelect* = 8;
- kAudioSetTrebleSelect* = 9;
- kAudioGetOutputDeviceSelect* = 10;
- kAudioMuteOnEventSelect* = 129;
-
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
- (* Sound Manager 3.0 utilities*)
-
- PROCEDURE OpenMixerSoundComponent*(outputDescription: SoundComponentDataPtr; outputFlags: LONGINT; VAR mixerComponent: Components.ComponentInstance): Types.OSErr;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $203C, $0614, $0018, $A800;
- (*$END*)
- PROCEDURE CloseMixerSoundComponent*(ci: Components.ComponentInstance): Types.OSErr;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $203C, $0218, $0018, $A800;
- (*$END*)
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
- (* basic sound component functions*)
- PROCEDURE SoundComponentInitOutputDevice*(ti: Components.ComponentInstance; actions: LONGINT): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 4, 1, $7000, $A82A;
- (*$END*)
- PROCEDURE SoundComponentSetSource*(ti: Components.ComponentInstance; sourceID: SoundSource; source: Components.ComponentInstance): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 8, 2, $7000, $A82A;
- (*$END*)
- PROCEDURE SoundComponentGetSource*(ti: Components.ComponentInstance; sourceID: SoundSource; VAR source: Components.ComponentInstance): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 8, 3, $7000, $A82A;
- (*$END*)
- PROCEDURE SoundComponentGetSourceData*(ti: Components.ComponentInstance; VAR sourceData: SoundComponentDataPtr): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 4, 4, $7000, $A82A;
- (*$END*)
- PROCEDURE SoundComponentSetOutput*(ti: Components.ComponentInstance; requested: SoundComponentDataPtr; VAR actual: SoundComponentDataPtr): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 8, 5, $7000, $A82A;
- (*$END*)
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
- (* junction methods for the mixer, must be called at non-interrupt level*)
- PROCEDURE SoundComponentAddSource*(ti: Components.ComponentInstance; VAR sourceID: SoundSource): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 4, $0101, $7000, $A82A;
- (*$END*)
- PROCEDURE SoundComponentRemoveSource*(ti: Components.ComponentInstance; sourceID: SoundSource): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 4, $0102, $7000, $A82A;
- (*$END*)
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
- (* info methods*)
- PROCEDURE SoundComponentGetInfo*(ti: Components.ComponentInstance; sourceID: SoundSource; selector: Types.OSType; infoPtr: (*ΔΔUNIVΔΔ*) Types.Ptr): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 12, $0103, $7000, $A82A;
- (*$END*)
- PROCEDURE SoundComponentSetInfo*(ti: Components.ComponentInstance; sourceID: SoundSource; selector: Types.OSType; infoPtr: (*ΔΔUNIVΔΔ*) Types.Ptr): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 12, $0104, $7000, $A82A;
- (*$END*)
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
- (* control methods*)
- PROCEDURE SoundComponentStartSource*(ti: Components.ComponentInstance; count: INTEGER; VAR sources: SoundSource): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 6, $0105, $7000, $A82A;
- (*$END*)
- PROCEDURE SoundComponentStopSource*(ti: Components.ComponentInstance; count: INTEGER; VAR sources: SoundSource): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 6, $0106, $7000, $A82A;
- (*$END*)
- PROCEDURE SoundComponentPauseSource*(ti: Components.ComponentInstance; count: INTEGER; VAR sources: SoundSource): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 6, $0107, $7000, $A82A;
- (*$END*)
- PROCEDURE SoundComponentPlaySourceBuffer*(ti: Components.ComponentInstance; sourceID: SoundSource; pb: SoundParamBlockPtr; actions: LONGINT): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 12, $0108, $7000, $A82A;
- (*$END*)
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
- (* interface for Audio Components*)
- (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
- (*Volume is described as a value between 0 and 1, with 0 indicating minimum
- volume and 1 indicating maximum volume; if the device doesn't support
- software control of volume, then a value of unimpErr is returned, indicating
- that these functions are not supported by the device*)
- PROCEDURE AudioGetVolume*(ac: Components.ComponentInstance; whichChannel: INTEGER; VAR volume: ShortFixed): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 6, 0, $7000, $A82A;
- (*$END*)
- PROCEDURE AudioSetVolume*(ac: Components.ComponentInstance; whichChannel: INTEGER; volume: ShortFixed): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 4, 1, $7000, $A82A;
- (*$END*)
- (*If the device doesn't support software control of mute, then a value of unimpErr is*)
- (*returned, indicating that these functions are not supported by the device*)
- PROCEDURE AudioGetMute*(ac: Components.ComponentInstance; whichChannel: INTEGER; VAR mute: INTEGER): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 6, 2, $7000, $A82A;
- (*$END*)
- PROCEDURE AudioSetMute*(ac: Components.ComponentInstance; whichChannel: INTEGER; mute: INTEGER): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 4, 3, $7000, $A82A;
- (*$END*)
- (*AudioSetToDefaults causes the associated device to reset its volume and mute values*)
- (*(and perhaps other characteristics, e.g. attenuation) to "factory default" settings*)
- PROCEDURE AudioSetToDefaults*(ac: Components.ComponentInstance): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 0, 4, $7000, $A82A;
- (*$END*)
- (*This routine is required; it must be implemented by all audio components*)
- PROCEDURE AudioGetInfo*(ac: Components.ComponentInstance; info: AudioInfoPtr): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 4, 5, $7000, $A82A;
- (*$END*)
- PROCEDURE AudioGetBass*(ac: Components.ComponentInstance; whichChannel: INTEGER; VAR bass: INTEGER): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 6, 6, $7000, $A82A;
- (*$END*)
- PROCEDURE AudioSetBass*(ac: Components.ComponentInstance; whichChannel: INTEGER; bass: INTEGER): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 4, 7, $7000, $A82A;
- (*$END*)
- PROCEDURE AudioGetTreble*(ac: Components.ComponentInstance; whichChannel: INTEGER; VAR Treble: INTEGER): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 6, 8, $7000, $A82A;
- (*$END*)
- PROCEDURE AudioSetTreble*(ac: Components.ComponentInstance; whichChannel: INTEGER; Treble: INTEGER): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 4, 9, $7000, $A82A;
- (*$END*)
- PROCEDURE AudioGetOutputDevice*(ac: Components.ComponentInstance; VAR outputDevice: Components.Component): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 4, 10, $7000, $A82A;
- (*$END*)
- (*This is routine is private to the AudioVision component. It enables the watching of the mute key.*)
- PROCEDURE AudioMuteOnEvent*(ac: Components.ComponentInstance; muteOnEvent: INTEGER): Components.ComponentResult;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, 2, 129, $7000, $A82A;
- (*$END*)
- CONST
- uppSoundParamProcInfo* = $000000D0; (* PROCEDURE (4 byte param): 1 byte result; *)
-
- PROCEDURE NewSoundParamProc*(userRoutine: SoundParamProcPtr): SoundParamUPP;
- (*$IF NOT GENERATINGCFM *)
- INLINE PASCAL $2E9F;
- (*$END*)
-
- PROCEDURE CallSoundParamProc*(VAR pb: SoundParamBlockPtr; userRoutine: SoundParamUPP): BOOLEAN;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $205F, $4E90;
- (*$END*)
-
- (* $ALIGN RESET*)
- (* $POP*)
-
- END SoundComponents.
-